'''
Created on 28 sept. 2010
@author: Marc CARRE
@contact: carre.marc@gmail.com
@license: GNU GPLv3
@version: 1.0
'''

import unittest
import time
from DataSetGenerator import DataSetGenerator

class PerformanceTest(unittest.TestCase):

    def test10(self):
        tStart = time.clock()
        params = ["x", "y"]
        spaces = {"A":"y>x**3","B":"y<x**3"} 
        numPoints = 10
        filePath = "testFloatPerformance10.txt"
        g = DataSetGenerator(params, [[-2,2], [-8,8]], spaces, numPoints, "FLOAT", filePath)
        g.generate()
        tStop = time.clock()
        tSpan = tStop - tStart
        print("\nDone in: " + str(tSpan) + " seconds.")
        self.assertTrue(tSpan < 1)
        
    def test100(self):
        tStart = time.clock()
        params = ["x", "y"]
        spaces = {"A":"y>x**3","B":"y<x**3"} 
        numPoints = 100
        filePath = "testFloatPerformance100.txt"
        g = DataSetGenerator(params, [[-2,2], [-8,8]], spaces, numPoints, "FLOAT", filePath)
        g.generate()
        tStop = time.clock()
        tSpan = tStop - tStart
        print("\nDone in: " + str(tSpan) + " seconds.")
        self.assertTrue(tSpan < 1)

    def test1000(self):
        tStart = time.clock()
        params = ["x", "y"]
        spaces = {"A":"y>x**3","B":"y<x**3"} 
        numPoints = 1000
        filePath = "testFloatPerformance1000.txt"
        g = DataSetGenerator(params, [[-2,2], [-8,8]], spaces, numPoints, "FLOAT", filePath)
        g.generate()
        tStop = time.clock()
        tSpan = tStop - tStart
        print("\nDone in: " + str(tSpan) + " seconds.")
        self.assertTrue(tSpan < 1)

    def test10000(self):
        tStart = time.clock()
        params = ["x", "y"]
        spaces = {"A":"y>x**3","B":"y<x**3"} 
        numPoints = 10000
        filePath = "testFloatPerformance10000.txt"
        g = DataSetGenerator(params, [[-2,2], [-8,8]], spaces, numPoints, "FLOAT", filePath)
        g.generate()
        tStop = time.clock()
        tSpan = tStop - tStart
        print("\nDone in: " + str(tSpan) + " seconds.")
        self.assertTrue(tSpan < 1)

    def test100000(self):
        tStart = time.clock()
        params = ["x", "y"]
        spaces = {"A":"y>x**3","B":"y<x**3"} 
        numPoints = 100000
        filePath = "testFloatPerformance100000.txt"
        g = DataSetGenerator(params, [[-2,2], [-8,8]], spaces, numPoints, "FLOAT", filePath)
        g.generate()
        tStop = time.clock()
        tSpan = tStop - tStart
        print("\nDone in: " + str(tSpan) + " seconds.")
        self.assertTrue(tSpan < 10)

    def test1000000(self):
        tStart = time.clock()
        params = ["x", "y"]
        spaces = {"A":"y>x**3","B":"y<x**3"} 
        numPoints = 1000000
        filePath = "testFloatPerformance1000000.txt"
        g = DataSetGenerator(params, [[-2,2], [-8,8]], spaces, numPoints, "FLOAT", filePath)
        g.generate()
        tStop = time.clock()
        tSpan = tStop - tStart
        print("\nDone in: " + str(tSpan) + " seconds.")
        self.assertTrue(tSpan < 100)

if __name__ == "__main__":
    #import sys;sys.argv = ['', 'Test.testName']
    unittest.main()